'''
    该案例演示了set集合
'''
# 创建set
# set = set([1, 2, 3, 4, 5])
# set1 = {1, 2, 3, 4, 5}
# set2 = range(10)
# print(set1,type(set1))
# print(set2,type(set2))
# 定义空set,如果想声明一个空set,不能用下面的方式,下面创建一个空的dict
set4 = {}
print(set4,type(set4))   # {} <class 'dict'>
set3 = set()
print(set3,type(set3))  # set() <class 'set'>

# {0, 2, 4, 6, 8, 10, 12, 14, 16, 18}
# set = {i*2 for i in range(10)}
# # 添加元素
# set.add(5)
# set.add(9)
# print(set)
# # 删除元素
# set.remove(8)
# print(set)
# print(len(set))

# 检查成员是否为集合中元素
# set1 = {1, 2, 3}
# print( 6 in set1)

# 获取集合长度
# set1 = {1, 2, 3}
# print(len(set1))

# 获取集合中的set中的 最大，最小，求和
# set1 = {1, 2, 3}
# print(max(set1))
# print(min(set1))
# print(sum(set1))

# # 遍历
# set2 = {1, 2, 3}
# for item in set2:
#     print(item)
#
# # 集合中的元素不能重复
# set1 = {1, 2, 3}
# set1.add(1)
# set1.add(1)
# set1.add(1)
# print(set1)


